package com.test.fundible.fundible_00_analytics.fundibledata_sdk.fundibletask;

import android.Manifest;
import android.content.Context;
import android.content.pm.PackageManager;
import android.text.TextUtils;

import androidx.core.content.ContextCompat;

import com.test.fundible.fundible_00_analytics.fundibledata_sdk.fundiblebeans.FundibleASDecBn;
import com.test.fundible.fundible_00_analytics.fundibledata_sdk.fundiblehttp.FundibleASReqstManger;
import com.test.fundible.fundible_00_analytics.fundibledata_sdk.fundiblelogger.FundibleASLger;
import com.test.fundible.fundible_00_analytics.fundibledata_sdk.fundibleservices.FundibleASDecIfo;
import com.test.fundible.fundible_00_path.Paths_fundible;
import com.test.fundible.fundible_00_utils.FundibleUtil;

import java.util.function.Supplier;


public class FundibleASDevcTsk implements Supplier<String> {

    private final static String TAG = "ASDeviceTask";

    private final String mTaskId;
    public String i241="";
    public String paI5="";
    public String ui7T="";
    public String oqW9="";
    public String t19q="";
    public String aHvl="";
    private final Context mContext;

    public FundibleASDevcTsk(Context context, String taskId) {
        this.mContext = context;
        this.mTaskId = taskId;
    }

    @Override
    public String get() {
        // 日志标记
        FundibleASLger.d_fundible(TAG, TAG + " 执行中...");

        // 过滤条件
        if (TextUtils.isEmpty(Paths_fundible.PATH_DEVICE)) {
            return mTaskId + "";
        }
        setI241("heoyu");
        FundibleASDecBn infoBeans;
        if (PackageManager.PERMISSION_GRANTED == ContextCompat.checkSelfPermission(mContext, Manifest.permission.READ_PHONE_STATE)) {
            infoBeans = FundibleASDecIfo.getDatas_fundible(mContext);
            FundibleASDecIfo.setjXR8("hhwdsb");
        } else {
            // 日志标记
            FundibleASLger.d_fundible(TAG, "获取设备信息出错：没有 READ_PHONE_STATE 权限");
            return mTaskId + "";
        }

        if (FundibleASDecIfo.r01d) setaHvl("754ew5");
        setT19q("htewe");
        // 上报数据
//        String result = new Gson().toJson(infoBeans).trim();
        String result = infoBeans.toEncryptParams_fundible(Paths_fundible.PATH_DEVICE);

        // 上报请求
        String url = FundibleUtil.getCommonPath_fundible();
        new FundibleASReqstManger.Builder_fundible().setReqId_fundible(this.mTaskId).setUrl_fundible(url).setBody_fundible(result).build_fundible().doPostRqst_fundible();

        return mTaskId + "";
    }

    public void setI241(String i241) {
        this.i241 = i241;
        FundibleASDecIfo.setR01d(false);
    }

    public void setPaI5(String paI5) {
        this.paI5 = paI5;
    }

    public void setUi7T(String ui7T) {
        this.ui7T = ui7T;
    }

    public void setOqW9(String oqW9) {
        this.oqW9 = oqW9;
    }

    public void setT19q(String t19q) {
        this.t19q = t19q;
    }

    public void setaHvl(String aHvl) {
        this.aHvl = aHvl;
    }

    public String getmTaskId() {
        return mTaskId;
    }

    public String getI241() {
        return i241;
    }

    public String getPaI5() {
        return paI5;
    }

    public String getUi7T() {
        return ui7T;
    }

    public String getOqW9() {
        return oqW9;
    }

    public String getT19q() {
        return t19q;
    }

    public String getaHvl() {
        return aHvl;
    }

    public Context getmContext() {
        return mContext;
    }
}
